<template>
    <div>
        <a-popconfirm title="确定删除该数据?" ok-text="确定" cancel-text="取消" @confirm="handClick">
            <a-tooltip placement="top" :title="ids ? '删除' : ''">
                <a-button class="deleteBtn" type="link" :size="ids ? 'small' : 'default'" :ghost="ids ? true : false">
                    <Icons type="delete"></Icons>
                </a-button>
            </a-tooltip>
        </a-popconfirm>
    </div>
</template>
<script>
import Icons from './Icons.vue';
export default {
    name: 'DeleteButton',
    components: {
        Icons
    },
    props: {
        // 菜单id
        menuId: {
            type: [String, Number],
        },
        // 数据
        ids: {
            type: [String, Number],
        },
        onRefresh: {
            type: Function,
            default: () => { }
        },
        type: {
            type: String,
            default: 'default'
        }
    },
    data() {
        return {}
    },
    methods: {
        handClick() {
            let url;
            let data = {};
            if (Number(this.menuId) == 6) {
                data['userid'] = this.ids
                url = this.$delsguser;
            } else if (Number(this.menuId) == 7) {
                data['roleid'] = this.ids
                url = this.$delmenurole;
            } else if (Number(this.menuId) == 8) {
                data['roleid'] = this.ids
                url = this.$deldeptdatarole;
            } else if (Number(this.menuId) == 91) {
                data['id'] = this.ids
                url = this.$deleteProcessNode;
            } else if (Number(this.menuId) == 92) {
                data['id'] = this.ids
                url = this.$deleteChatGroup;
            } else if (Number(this.menuId) == 993) {
                data['id'] = this.ids
                url = this.$deleteFile;
            } else if (Number(this.menuId) == 996) {
                data['id'] = this.ids
                url = this.$dkdelete;
            } else if (Number(this.menuId) == 977) {
                data['id'] = this.ids
                url = this.$mhqtzDelete;
            } else if (Number(this.menuId) == 9979) {
                data['id'] = this.ids
                url = this.$deleteProcessReminder;
            }
            if (!url) {
                return
            }
            this.getAxios(url, data)
                .then((res) => {
                    if (res.code === 200) {
                        this.$message.success(res.msg || res.data);
                        this.onRefresh();
                    }
                })
                .catch((err) => {
                }).finally(() => {
                });
        }
    }
}
</script>
<style lang="less" scoped>
.deleteBtn {
    color: red;
}
</style>